package com.hm.day45e.biz;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hm.day45e.dao.UsersMapper;
import com.hm.day45e.model.Users;
import com.hm.day45e.util.BusinessException;
import com.hm.day45e.util.Constants;
import com.hm.day45e.util.EncryptHelper;



@Service
public class UsersBiz {
	@Resource
	private UsersMapper usersDAO;
	
	public Users login(Users users)throws BusinessException{
		String encryptedPwd = EncryptHelper.getMD5(users.getPwd());
		try {
			return usersDAO.findByUsernameAndPwd(users.getUsername(), encryptedPwd);
		} catch (Exception e) {
			e.printStackTrace();
			throw new BusinessException(Constants.LOGIN_EXCEPTION_CODE);
		}
	}
}
